/**
 * @param {number[]} nums
 * @return {boolean}
 */
var containsDuplicate = function (nums) {
  let result = false //假设数组中的每个元素都互不相同
  let set = new Set()
  for (let i = 0; i < nums.length; i++) {
    if(!set.has(nums[i])){
      set.add(nums[i])
    }else{
      result =true
    }
  }

  return result
};

let nums = [1, 2, 3, 1]
console.log(containsDuplicate(nums))